package com.yq.day29;


import java.util.concurrent.TimeUnit;

/**
 * @author 3307235355@qq.com
 * @description
 * @since 2022/06/29 10:58
 */
public class Demo03 {
    public static Object object = new Object();

    public static void main(String[] args) {
        //创建一个wait

        new Thread(() -> {
            synchronized (object) {
                try {
                    System.out.println("wait before");
                    TimeUnit.SECONDS.sleep(5);
                    object.wait();
                    System.out.println("wait after");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        //休眠main

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //创建一个启动的线程
        new Thread(() -> {
            System.out.println("t2 已经执行");
            synchronized (object) {
                System.out.println("t2 before");
                // object.notify();
            }
        }).start();
    }
}
